Skip to content

test: key-token round-trip and path validation coverage#15

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursor/missing-test-coverage-e35a
Draft

test: key-token round-trip and path validation coverage#15
cursor[bot] wants to merge 1 commit intomainfrom
cursor/missing-test-coverage-e35a

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor bot commented Apr 9, 2026

Summary

Adds Vitest coverage for shared helpers used on high-blast-radius paths (S3 key encoding, collection slug / relative path validation, root prefix).

Risky behavior now covered

  • URL-safe base64 encode/decode for object keys (encodeObjectKeyToken / decodeObjectKeyToken): used for token digests and query-safe key material; regressions break lookups or leak malformed keys.
  • Path and slug guards (assertValidCollectionSlug, assertSafeRelativePath, assertKeyUnderRoot, fullObjectKey, splitObjectKeyAfterRoot): same rules enforced by the CI file API before S3 reads; catches traversal, wrong roots, and invalid secret paths.

Test files added/updated

  • src/lib/key-token.test.ts (new)
  • src/lib/paths.test.ts (new)

Why this reduces regression risk

These utilities are small but shared: a bad base64 padding or alphabet change, or a loosened slug/path check, can affect authz boundaries and object resolution across the app. The tests pin expected round-trips and rejection cases without coupling to HTTP or Prisma, so they stay fast and deterministic.

Validation

  • npm run test (Vitest): all tests pass.
Open in Web View Automation 

- Round-trip URL-safe base64 for object keys (used by token hashing and query params)
- Assert collection slug, relative path, root prefix, and full key split behavior for CI file API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant